package ${package.DTO};

import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.NotEmpty;
import org.hibernate.validator.constraints.Length;
<#list table.importPackages as pkg>
<#if pkg!='import com.baomidou.mybatisplus.annotation.IdType;' && pkg!='import com.baomidou.mybatisplus.annotation.TableId;'>
import ${pkg};
</#if>
</#list>

/**
* ${table.comment!}
*
* @author ${author} created on ${date}
*/
@Data
@ApiModel(description = "${table.comment!}dto")
public class ${entity}DTO implements Serializable {
    private static final long serialVersionUID = 1L;
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>

    <#if field.comment!?length gt 0>
    <#if !field.nullAble>
    <#if field.propertyType == 'String'>
    @NotEmpty(message = "${field.comment}不能为空")
    <#else>
    @NotNull(message = "${field.comment}不能为空")
    </#if>
    </#if>
    <#if  1!=1 && field.propertyType == 'String' && field.dataLength gt 0>
    @Length(max = ${field.dataLength}, message = "${field.comment}不能超过${field.dataLength}个字符")
    </#if>
    @ApiModelProperty("${field.comment}")
    </#if>
    <#if field.propertyType == 'Date' || field.propertyType == 'LocalDate'>
    @DateTimeFormat(pattern="yyyy-MM-dd")
    <#elseif field.propertyType == 'Timestamp' || field.propertyType == 'LocalDateTime'>
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    </#if>
    private ${field.propertyType} ${field.propertyName};
</#list>
<#------------  END 字段循环遍历  ---------->

<#if !entityLombokModel>
    <#list table.fields as field>
        <#if field.propertyType == "boolean">
            <#assign getprefix="is"/>
        <#else>
            <#assign getprefix="get"/>
        </#if>
        public ${field.propertyType} ${getprefix}${field.capitalName}() {
        return ${field.propertyName};
        }

        <#if entityBuilderModel>
            public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        <#else>
            public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        </#if>
        this.${field.propertyName} = ${field.propertyName};
        <#if entityBuilderModel>
            return this;
        </#if>
        }
    </#list>
</#if>

<#if entityColumnConstant>
    <#list table.fields as field>
        public static final String ${field.name?upper_case} = "${field.name}";

    </#list>
</#if>
<#if activeRecord>
    @Override
    protected Serializable pkVal() {
    <#if keyPropertyName??>
        return this.${keyPropertyName};
    <#else>
        return null;
    </#if>
    }

</#if>
<#if !entityLombokModel>
    @Override
    public String toString() {
    return "${entity}{" +
    <#list table.fields as field>
        <#if field_index==0>
            "${field.propertyName}=" + ${field.propertyName} +
        <#else>
            ", ${field.propertyName}=" + ${field.propertyName} +
        </#if>
    </#list>
    "}";
    }
</#if>
}

